package com.rms.hkpc.adapter;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.rms.hkpc.R;
import com.rms.hkpc.activity.AddHocActivity;
import com.rms.hkpc.activity.ImagePreviewActivity;
import com.rms.hkpc.adapter.base.BaseAdapter;
import com.rms.hkpc.adapter.base.BaseViewHolder;
import com.rms.hkpc.constant.AllConstants;
import com.rms.hkpc.db.dto.ParamValDto;
import com.rms.hkpc.db.dto.WorksOrderDto;
import com.rms.hkpc.util.OKHttpUtil;

import java.util.List;

public class WorkOrderInsightAdapter extends BaseAdapter<WorksOrderDto> {

    private Activity activity;

    public WorkOrderInsightAdapter(Activity activity,Context context, List<WorksOrderDto> mDatas, int layoutId) {
        super(context, mDatas, layoutId);
        this.activity = activity;
    }

    @Override
    public void convert(BaseViewHolder holder, WorksOrderDto item, int position) {
        holder.setText(R.id.tv_parameter, item.getName() == null ? "" : item.getName());
        holder.setText(R.id.tv_value, item.getVal() == null ? "/" : String.valueOf(item.getVal()));
        holder.setText(R.id.tv_remark, item.getRemarks() == null || item.getRemarks().isEmpty() ? "" : item.getRemarks().get(0).getRemark());
        if (item.getPhotos() != null && !item.getPhotos().isEmpty()) {
            holder.setImageResource(activity, R.id.iv_photo, OKHttpUtil.IMG_URL + item.getPhotos().get(0).getPhoto(), new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onItemChildrenClickListener.OnItemChildrenClickListener(v,position);
                }
            });
        }else {
            holder.setVisibility(R.id.iv_photo,View.INVISIBLE);
        }
    }
}
